import React, { createContext } from "react";

const defaultUser: User = {
  name: "tom",
  age: 18
}

const AppContext = createContext<Partial<IContext>>({})

export function ContextProvider({children}:Children){
  const [context, setContext] = React.useState({user:defaultUser})

  return (
    <AppContext.Provider value={{context, setContext}}>{children}</AppContext.Provider>
  )
}

export function useAppContext(){
  return React.useContext(AppContext)
}